package com.takanafu.haru.code{
	import mx.collections.ArrayCollection;
	
	public class CodeDotCall extends CodeBase{
		private var code:CodeBase;
		private var symbol:CodeSymbol;
		private var list:ArrayCollection;
		
		public function CodeDotCall(c:CodeBase,sym:CodeSymbol,l:ArrayCollection){
			this.code = c;
			this.symbol = sym;
			this.list = l;
		}
		
		override public function run():CodeBase{
			var c:CodeBase;
			
			c = code.run();
			if(this.list != null){
				var list2:ArrayCollection = new ArrayCollection();
				var count:int = this.list.length;
				
				for(var i:int = 0;i < count;i++){
					var c1:CodeBase = this.list.getItemAt(i) as CodeBase;
					var c2:CodeBase = c1 != null ? c1.run() as CodeBase : null;
					
					if(c2 != null){
						this.list.addItem(c2);
					}
				} 
			}
			c = c.method(this.symbol,this.list);
			
			return c;
		}
	}
}